home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 5 / MacMania 5.toast / / Internet software / Analog 2.0 / Analog 2.0 Src / analform.c < prev    next >
C/C++ Source or Header  |  1997-02-07  |  16KB  |  712 lines

  1. /* analform.c 2.0 -- parse the output of the analog form interface */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7.  
  8. extern FILE *popen();  /* to stop gcc complaining */
  9. extern int pclose();
  10. extern int putenv();
  11.  
  12. /* You must change the next line to indicate where the analog program lives */
  13.  
  14. #define COMMAND "/usr/local/etc/httpd/analog/analog"
  15. #define MAXARGLENGTH (2048)   /* should be plenty */
  16. #define OK (0)
  17. #define ERR (-1)
  18. #define STRLENGTH (64)
  19.  
  20. typedef int flag;
  21.  
  22. int unhttp(char *url)     /* converts back all http special characters */
  23. {
  24.   char *tempp;
  25.   char tempstr[MAXARGLENGTH];
  26.   int i;
  27.  
  28.   /* firstly, change +'s into spaces */
  29.  
  30.   for (i = strlen(url) - 1; i >= 0; i--) {
  31.     if (url[i] == '+')
  32.       url[i] = ' ';
  33.   }
  34.  
  35.   /* secondly change %7E to ~, etc. */
  36.  
  37.   tempp = url;
  38.   while ((tempp = strchr(tempp, '%')) != NULL) {
  39.     sscanf(tempp + 1, "%2x", &i);
  40.     if (i >= 0x20 && i < 0x7F) {
  41.       *tempp = i;
  42.       strcpy(tempstr, tempp + 3);
  43.       strcpy(tempp + 1, tempstr);
  44.       /* strcpy(tempp + 1, tempp + 3) may not be safe on all machines
  45.      (overlapping arguments) */
  46.     }
  47.     tempp++;
  48.   }
  49.  
  50.   /* Finally, check no unsafe characters. */
  51.  
  52.   for (tempp = url; *tempp != '\0'; tempp++) {
  53.     if (*tempp == ';' || *tempp == '\n' || *tempp == '\r' || *tempp == '`' ||
  54.     *tempp == '|' || *tempp == '<' || *tempp == '>')
  55.       return(ERR);
  56.   }
  57.  
  58.   return(OK);
  59. }
  60.  
  61. void genopts(FILE *thepipe, char name[9], int sortby, char *astr, char *cstr)
  62. {
  63. if (sortby <= 4 && sortby >= 0) {
  64.   fprintf(thepipe, "%sSORTBY ", name);
  65.   if (sortby == 4)
  66.     fprintf(thepipe, "PAGES\n");
  67.   else if (sortby == 3)
  68.     fprintf(thepipe, "RANDOM\n");
  69.   else if (sortby == 2)
  70.     fprintf(thepipe, "ALPHABETICAL\n");
  71.   else if (sortby == 1)
  72.     fprintf(thepipe, "BYTES\n");
  73.   else if (sortby == 0)
  74.     fprintf(thepipe, "REQUESTS\n");
  75.   if (sortby == 1) {
  76.     if (cstr[0] != '\0')
  77.       fprintf(thepipe, "%sMINBYTES %s\n", name, cstr);
  78.   }
  79.   else if (sortby == 4) {
  80.     if (astr[0] != '\0')
  81.       fprintf(thepipe, "%sMINPAGES %s\n", name, astr);
  82.   }
  83.   else {
  84.     if (astr[0] != '\0')
  85.       fprintf(thepipe, "%sMINREQS %s\n", name, astr);
  86.     }
  87.   }
  88. }
  89.  
  90. int main()
  91. {
  92.   extern void exit();
  93.  
  94.   /* the input */
  95.   char *argstring;
  96.   char *nextarg;
  97.   char *nextval;
  98.  
  99.   /* the variables that can be read in */
  100.   int xq = 2, mq = 2, Wq = 2, dq = 2, Dq = 2, hq = 2, oq = 2, Sq = 2, tq = 2;
  101.   int iq = 2, rq = 2, fq = 2, bq = 2, Bq = 2, cq = 2, eq = 2, Hq = 2, Vq = 0;
  102.   char mg = '\0', Wg = '\0', dg = '\0', Dg = '\0', hg = '\0', Hg = '\0';
  103.   int os = 6, Ss = 6, is = 6, rs = 6, fs = 6, Bs = 6, bs = 6, ts = 6;
  104.   int ou = 0, ch = 3, gr = 2;
  105.   char oa[STRLENGTH], Sa[STRLENGTH], ia[STRLENGTH], ra[STRLENGTH];
  106.   char ta[STRLENGTH], fa[STRLENGTH], Ba[STRLENGTH], ba[STRLENGTH];
  107.   char oc[STRLENGTH], Sc[STRLENGTH], ic[STRLENGTH], rc[STRLENGTH];
  108.   char tc[STRLENGTH], fc[STRLENGTH], Bc[STRLENGTH], bc[STRLENGTH];
  109.   int dirlevel = 0;
  110.   char reqtype = 'd', reqlinks = 'd';
  111.   char *from = NULL, *to = NULL;
  112.   char *fonly = NULL, *fign = NULL;
  113.   char *honly = NULL, *hign = NULL;
  114.   char *org = NULL, *home = NULL;
  115.   char *logfile = NULL, *reflog = NULL, *browlog = NULL;
  116.   char *errlog = NULL, *cachefile = NULL, *cg = NULL, *cm = NULL;
  117.   char *TZ = NULL;
  118.   char TZenv[STRLENGTH];
  119.   int wa = 1;
  120.  
  121.   FILE *thepipe;
  122.   int ret;
  123.  
  124.   oa[0] = '\0';
  125.   Sa[0] = '\0';
  126.   ia[0] = '\0';
  127.   ra[0] = '\0';
  128.   fa[0] = '\0';
  129.   ba[0] = '\0';
  130.   Ba[0] = '\0';
  131.   oc[0] = '\0';
  132.   Sc[0] = '\0';
  133.   ic[0] = '\0';
  134.   rc[0] = '\0';
  135.   fc[0] = '\0';
  136.   bc[0] = '\0';
  137.   Bc[0] = '\0';
  138.  
  139.   if ((argstring = getenv("QUERY_STRING")) == NULL) {
  140.     printf("Content-type: text/plain\n\n");
  141.     printf("Error: cannot find environment variable QUERY_STRING\n");
  142.     exit(ERR);
  143.   }
  144.  
  145.   if (strlen(argstring) >= MAXARGLENGTH - 1) {
  146.     fprintf(stderr, "Analog form interface: Security warning on request from %s (%s): QUERY_STRING too long\n",
  147.      (getenv("REMOTE_HOST") == NULL)?"unknown host":getenv("REMOTE_HOST"),
  148.      (getenv("REMOTE_ADDR") == NULL)?"unknown address":getenv("REMOTE_ADDR"));
  149.     printf("Content-type: text/plain\n\n");
  150.     printf("Error in QUERY_STRING\n");
  151.     exit(ERR);
  152.   }
  153.  
  154.   ret = unhttp(argstring);
  155.   if (ret == ERR) {      /* suspicious characters in argstring */
  156.     fprintf(stderr, "Analog form interface: Security warning on request from %s (%s): QUERY_STRING contains unusual characters\n",
  157.      (getenv("REMOTE_HOST") == NULL)?"unknown host":getenv("REMOTE_HOST"),
  158.      (getenv("REMOTE_ADDR") == NULL)?"unknown address":getenv("REMOTE_ADDR"));
  159.     printf("Content-type: text/plain\n\n");
  160.     printf("Error in QUERY_STRING\n");
  161.     exit(ERR);
  162.   }
  163.  
  164.   nextarg = strtok(argstring, "&");
  165.  
  166.   while (nextarg != NULL) {
  167.     nextval = strchr(nextarg, '=') + 1;
  168.     if (nextval[0] != '\0') {
  169.       switch(nextarg[0]) {
  170.       case 'b':
  171.     switch(nextarg[1]) {
  172.     case 'a':
  173.       strncpy(ba, nextval, STRLENGTH - 1);
  174.       break;
  175.     case 'b':
  176.       strcpy(ba, "-");
  177.       strncat(ba, nextval, STRLENGTH - 2);
  178.       break;
  179.     case 'c':
  180.       strncpy(bc, nextval, STRLENGTH - 1);
  181.       break;
  182.     case 'd':
  183.       strcpy(bc, "-");
  184.       strncat(bc, nextval, STRLENGTH - 2);
  185.       break;
  186.     case 'q':
  187.       bq = atoi(nextval);
  188.       break;
  189.     case 's':
  190.       bs = atoi(nextval);
  191.       break;
  192.     }
  193.     break;
  194.       case 'B':
  195.     switch(nextarg[1]) {
  196.     case 'a':
  197.       strncpy(Ba, nextval, STRLENGTH - 1);
  198.       break;
  199.     case 'b':
  200.       strcpy(Ba, "-");
  201.       strncat(Ba, nextval, STRLENGTH - 2);
  202.       break;
  203.     case 'c':
  204.       strncpy(Bc, nextval, STRLENGTH - 1);
  205.       break;
  206.     case 'd':
  207.       strcpy(Bc, "-");
  208.       strncat(Bc, nextval, STRLENGTH - 2);
  209.       break;
  210.     case 'q':
  211.       Bq = atoi(nextval);
  212.       break;
  213.     case 's':
  214.       Bs = atoi(nextval);
  215.       break;
  216.     }
  217.     break;
  218.       case 'c':
  219.     switch (nextarg[1]) {
  220.     case 'g':
  221.       cg = nextval;
  222.       break;
  223.     case 'h':
  224.       ch = atoi(nextval);
  225.       break;
  226.     case 'm':
  227.       cm = nextval;
  228.       break;
  229.     case 'q':
  230.       cq = atoi(nextval);
  231.       break;
  232.     }
  233.     break;
  234.       case 'd':
  235.     switch(nextarg[1]) {
  236.     case 'g':
  237.       dg = nextval[0];
  238.       break;
  239.     case 'q':
  240.       dq = atoi(nextval);
  241.       break;
  242.     }
  243.     break;
  244.       case 'D':
  245.     switch(nextarg[1]) {
  246.     case 'g':
  247.       Dg = nextval[0];
  248.       break;
  249.     case 'q':
  250.       Dq = atoi(nextval);
  251.       break;
  252.     }
  253.     break;
  254.       case 'e':
  255.     eq = atoi(nextval);
  256.     break;
  257.       case 'f':
  258.     switch(nextarg[1]) {
  259.     case 'a':
  260.       strncpy(fa, nextval, STRLENGTH - 1);
  261.       break;
  262.     case 'b':
  263.       strcpy(fa, "-");
  264.       strncat(fa, nextval, STRLENGTH - 2);
  265.       break;
  266.     case 'c':
  267.       strncpy(fc, nextval, STRLENGTH - 1);
  268.       break;
  269.     case 'd':
  270.       strcpy(fc, "-");
  271.       strncat(fc, nextval, STRLENGTH - 2);
  272.       break;
  273.     case 'i':
  274.       fign = nextval;
  275.       break;
  276.     case 'q':
  277.       fq = atoi(nextval);
  278.       break;
  279.     case 'r':
  280.       from = nextval;
  281.       break;
  282.     case 's':
  283.       fs = atoi(nextval);
  284.       break;
  285.     case 'y':
  286.       fonly = nextval;
  287.       break;
  288.     }
  289.     break;
  290.       case 'g':
  291.     gr = atoi(nextval);
  292.     break;
  293.       case 'h':
  294.     switch(nextarg[1]) {
  295.     case 'g':
  296.       hg = nextval[0];
  297.       break;
  298.     case 'i':
  299.       hign = nextval;
  300.       break;
  301.     case 'o':
  302.       home = nextval;
  303.       break;
  304.     case 'q':
  305.       hq = atoi(nextval);
  306.       break;
  307.     case 'y':
  308.       honly = nextval;
  309.       break;
  310.     }
  311.     break;
  312.       case 'H':
  313.     switch(nextarg[1]) {
  314.     case 'g':
  315.       Hg = nextval[0];
  316.       break;
  317.     case 'q':
  318.       Hq = atoi(nextval);
  319.       break;
  320.     }
  321.     break;
  322.       case 'i':
  323.     switch(nextarg[1]) {
  324.     case 'a':
  325.       strncpy(ia, nextval, STRLENGTH - 1);
  326.       break;
  327.     case 'b':
  328.       strcpy(ia, "-");
  329.       strncat(ia, nextval, STRLENGTH - 2);
  330.       break;
  331.     case 'c':
  332.       strncpy(ic, nextval, STRLENGTH - 1);
  333.       break;
  334.     case 'd':
  335.       strcpy(ic, "-");
  336.       strncat(ic, nextval, STRLENGTH - 2);
  337.       break;
  338.     case 'e':
  339.       dirlevel = atoi(nextval);
  340.       break;
  341.     case 'q':
  342.       iq = atoi(nextval);
  343.       break;
  344.     case 's':
  345.       is = atoi(nextval);
  346.       break;
  347.     }
  348.     break;
  349.       case 'l':
  350.     switch(nextarg[1]) {
  351.     case 'b':
  352.       browlog = nextval;
  353.       break;
  354.     case 'c':
  355.       cachefile = nextval;
  356.       break;
  357.     case 'e':
  358.       errlog = nextval;
  359.       break;
  360.     case 'f':
  361.       reflog = nextval;
  362.       break;
  363.     case 'o':
  364.       logfile = nextval;
  365.       break;
  366.     }
  367.     break;
  368.       case 'm':
  369.     switch(nextarg[1]) {
  370.     case 'g':
  371.       mg = nextval[0];
  372.       break;
  373.     case 'q':
  374.       mq = atoi(nextval);
  375.       break;
  376.     }
  377.     break;
  378.       case 'o':
  379.     switch(nextarg[1]) {
  380.     case 'a':
  381.       strncpy(oa, nextval, STRLENGTH - 1);
  382.       break;
  383.     case 'b':
  384.       strcpy(oa, "-");
  385.       strncat(oa, nextval, STRLENGTH - 2);
  386.       break;
  387.     case 'c':
  388.       strncpy(oc, nextval, STRLENGTH - 1);
  389.       break;
  390.     case 'd':
  391.       strcpy(oc, "-");
  392.       strncat(oc, nextval, STRLENGTH - 2);
  393.       break;
  394.     case 'q':
  395.       oq = atoi(nextval);
  396.       break;
  397.     case 'r':
  398.       org = nextval;
  399.       break;
  400.     case 's':
  401.       os = atoi(nextval);
  402.       break;
  403.     case 'u':
  404.       ou = atoi(nextval);
  405.       break;
  406.     }
  407.     break;
  408.       case 'r':
  409.     switch(nextarg[1]) {
  410.     case 'a':
  411.       strncpy(ra, nextval, STRLENGTH - 1);
  412.       break;
  413.     case 'b':
  414.       strcpy(ra, "-");
  415.       strncat(ra, nextval, STRLENGTH - 2);
  416.       break;
  417.     case 'c':
  418.       strncpy(rc, nextval, STRLENGTH - 1);
  419.       break;
  420.     case 'd':
  421.       strcpy(rc, "-");
  422.       strncat(rc, nextval, STRLENGTH - 2);
  423.       break;
  424.     case 'l':
  425.       reqlinks = nextval[0];
  426.       break;
  427.     case 'q':
  428.       rq = atoi(nextval);
  429.       break;
  430.     case 's':
  431.       rs = atoi(nextval);
  432.       break;
  433.     case 't':
  434.       reqtype = nextval[0];
  435.       break;
  436.     }
  437.     break;
  438.       case 'S':
  439.     switch(nextarg[1]) {
  440.     case 'a':
  441.       strncpy(Sa, nextval, STRLENGTH - 1);
  442.       break;
  443.     case 'b':
  444.       strcpy(Sa, "-");
  445.       strncat(Sa, nextval, STRLENGTH - 2);
  446.       break;
  447.     case 'c':
  448.       strncpy(Sc, nextval, STRLENGTH - 1);
  449.       break;
  450.     case 'd':
  451.       strcpy(Sc, "-");
  452.       strncat(Sc, nextval, STRLENGTH - 2);
  453.       break;
  454.     case 'q':
  455.       Sq = atoi(nextval);
  456.       break;
  457.     case 's':
  458.       Ss = atoi(nextval);
  459.       break;
  460.     }
  461.     break;
  462.       case 't':
  463.     switch(nextarg[1]) {
  464.     case 'a':
  465.       strncpy(ta, nextval, STRLENGTH - 1);
  466.       break;
  467.     case 'b':
  468.       strcpy(ta, "-");
  469.       strncat(ta, nextval, STRLENGTH - 2);
  470.       break;
  471.     case 'c':
  472.       strncpy(tc, nextval, STRLENGTH - 1);
  473.       break;
  474.     case 'd':
  475.       strcpy(tc, "-");
  476.       strncat(tc, nextval, STRLENGTH - 2);
  477.       break;
  478.     case 'o':
  479.       to = nextval;
  480.       break;
  481.     case 'q':
  482.       tq = atoi(nextval);
  483.       break;
  484.     case 's':
  485.       ts = atoi(nextval);
  486.       break;
  487.     }
  488.     break;
  489.       case 'T':
  490.     TZ = nextval;
  491.     break;
  492.       case 'V':
  493.     Vq = atoi(nextval);
  494.     break;
  495.       case 'w':
  496.     wa = atoi(nextval);
  497.     break;
  498.       case 'W':
  499.     switch(nextarg[1]) {
  500.     case 'g':
  501.       Wg = nextval[0];
  502.       break;
  503.     case 'q':
  504.       Wq = atoi(nextval);
  505.       break;
  506.     }
  507.     break;
  508.       case 'x':
  509.     xq = 1;
  510.     break;
  511.       }
  512.     }
  513.     nextarg = strtok((char *)NULL, "&");
  514.   }
  515.  
  516.   /* OK, so we've read everything in, now send it to the program */
  517.   
  518.   if (TZ != NULL) {
  519.     strcpy(TZenv, "TZ=");
  520.     strcat(TZenv, TZ);
  521.     putenv(TZenv);
  522.   }
  523.  
  524.   if (Vq)
  525.     thepipe = stdout;
  526.  
  527.   if (!Vq && (thepipe = popen(COMMAND " +g-", "w")) == NULL) {
  528.     printf("Content-type: text/plain\n\n");
  529.     printf("Error: cannot start analog program at %s\n", COMMAND);
  530.   }
  531.  
  532.   else {
  533.     printf("Content-type: text/%s\n\n", (Vq || ou)?"plain":"html");
  534.     fflush(stdout);
  535.  
  536.     fprintf(thepipe, "OUTFILE stdout\n");
  537.  
  538.     if (cg != NULL)
  539.       fprintf(thepipe, "CONFIGFILE %s\n", cg);
  540.     if (xq < 2)
  541.       fprintf(thepipe, "GENERAL %s\n", xq?"ON":"OFF");
  542.     if (mq < 2)
  543.       fprintf(thepipe, "MONTHLY %s\n", mq?"ON":"OFF");
  544.     if (Wq < 2)
  545.       fprintf(thepipe, "WEEKLY %s\n", Wq?"ON":"OFF");
  546.     if (dq < 2)
  547.       fprintf(thepipe, "DAILY %s\n", dq?"ON":"OFF");
  548.     if (Dq < 2)
  549.       fprintf(thepipe, "FULLDAILY %s\n", Dq?"ON":"OFF");
  550.     if (hq < 2)
  551.       fprintf(thepipe, "HOURLY %s\n", hq?"ON":"OFF");
  552.     if (Hq < 2)
  553.       fprintf(thepipe, "FULLHOURLY %s\n", Hq?"ON":"OFF");
  554.     if (oq < 2)
  555.       fprintf(thepipe, "DOMAIN %s\n", oq?"ON":"OFF");
  556.     if (Sq < 2)
  557.       fprintf(thepipe, "FULLHOSTS %s\n", Sq?"ON":"OFF");
  558.     if (iq < 2)
  559.       fprintf(thepipe, "DIRECTORY %s\n", iq?"ON":"OFF");
  560.     if (rq < 2)
  561.       fprintf(thepipe, "REQUEST %s\n", rq?"ON":"OFF");
  562.     if (bq < 2)
  563.       fprintf(thepipe, "BROWSER %s\n", bq?"ON":"OFF");
  564.     if (Bq < 2)
  565.       fprintf(thepipe, "FULLBROWSER %s\n", Bq?"ON":"OFF");
  566.     if (cq < 2)
  567.       fprintf(thepipe, "STATUS %s\n", cq?"ON":"OFF");
  568.     if (eq < 2)
  569.       fprintf(thepipe, "ERROR %s\n", eq?"ON":"OFF");
  570.     if (fq < 2)
  571.       fprintf(thepipe, "REFERRER %s\n", fq?"ON":"OFF");
  572.     if (tq < 2)
  573.       fprintf(thepipe, "FILETYPE %s\n", tq?"ON":"OFF");
  574.     if (ch < 3)
  575.       fprintf(thepipe, "COUNTHOSTS %s\n",
  576.           (ch == 2)?"APPROX":(ch?"ON":"OFF"));
  577.     if (gr < 2)
  578.       fprintf(thepipe, "GRAPHICAL %s\n", gr?"ON":"OFF");
  579.  
  580.     if (mq && mg != '\0')
  581.       fprintf(thepipe, "MONTHGRAPH %c", mg);
  582.     if (Wq && Wg != '\0')
  583.       fprintf(thepipe, "WEEKGRAPH %c", Wg);
  584.     if (hq && hg != '\0')
  585.       fprintf(thepipe, "HOURGRAPH %c", hg);
  586.     if (Hq && Hg != '\0')
  587.       fprintf(thepipe, "FULLHOURGRAPH %c", Hg);
  588.     if (dq && dg != '\0')
  589.       fprintf(thepipe, "DAYGRAPH %c", dg);
  590.     if (Dq && Dg != '\0')
  591.       fprintf(thepipe, "FULLDAYGRAPH %c", Dg);
  592.  
  593.     if (oq)
  594.       genopts(thepipe, "DOM", os, oa, oc);
  595.     if (Sq)
  596.       genopts(thepipe, "HOST", Ss, Sa, Sc);
  597.     if (iq) {
  598.       genopts(thepipe, "DIR", is, ia, ic);
  599.       fprintf(thepipe, "DIRLEVEL %d\n", dirlevel);
  600.     }
  601.     if (rq) {
  602.       genopts(thepipe, "REQ", rs, ra, rc);
  603.       if (reqtype != 'd')
  604.     fprintf(thepipe, "REQINCLUDE %s\n", (reqtype == 'f')?"*":"pages");
  605.       if (reqlinks == 'n')
  606.     fprintf(thepipe, "LINKEXCLUDE *\n");
  607.       else if (reqlinks != 'd')
  608.     fprintf(thepipe, "LINKINCLUDE %s\n", (reqlinks == 'f')?"*":"pages");
  609.     }
  610.     if (bq)
  611.       genopts(thepipe, "BROW", bs, ba, bc);
  612.     if (Bq)
  613.       genopts(thepipe, "FULLBROW", Bs, Ba, Bc);
  614.     if (fq)
  615.       genopts(thepipe, "REF", fs, fa, fc);
  616.     if (tq)
  617.       genopts(thepipe, "TYPE", ts, ta, tc);
  618.  
  619.     if (ou < 3)
  620.       fprintf(thepipe, "OUTPUT %s\n",
  621.           (ou == 2)?"PREFORMATTED":((ou == 1)?"ASCII":"HTML"));
  622.  
  623.     fprintf(thepipe, "WARNINGS %s\n", wa?"ON":"OFF");
  624.  
  625.     if (from != NULL)
  626.       fprintf(thepipe, "FROM %s\n", from);
  627.     if (to != NULL)
  628.       fprintf(thepipe, "TO %s\n", to);
  629.     if (org != NULL)
  630.       fprintf(thepipe, "HOSTNAME \"%s\"\n", org);
  631.     if (home != NULL)
  632.       fprintf(thepipe, "HOSTURL %s\n", home);
  633.     else
  634.       fprintf(thepipe, "HOSTURL -\n");
  635.     
  636.     /* That just leaves the only's and ignore's and logfiles, which are a bit
  637.        more complicated as we have to parse them still. Recycle 'nextarg'. */
  638.  
  639.     nextarg = strtok(fonly, " ,");   /* split at spaces and commas */
  640.     while (nextarg != NULL) {
  641.       fprintf(thepipe, "FILEINCLUDE %s\n", nextarg);
  642.       nextarg = strtok((char *)NULL, " ,");
  643.     }
  644.  
  645.     nextarg = strtok(fign, " ,");
  646.     while (nextarg != NULL) {
  647.       fprintf(thepipe, "FILEEXCLUDE %s\n", nextarg);
  648.       nextarg = strtok((char *)NULL, " ,");
  649.     }
  650.  
  651.     nextarg = strtok(honly, " ,");
  652.     while (nextarg != NULL) {
  653.       fprintf(thepipe, "HOSTINCLUDE %s\n", nextarg);
  654.       nextarg = strtok((char *)NULL, " ,");
  655.     }
  656.  
  657.     nextarg = strtok(hign, " ,");
  658.     while (nextarg != NULL) {
  659.       fprintf(thepipe, "HOSTEXCLUDE %s\n", nextarg);
  660.       nextarg = strtok((char *)NULL, " ,");
  661.     }
  662.  
  663.     nextarg = strtok(browlog, " ,");
  664.     while (nextarg != NULL) {
  665.       fprintf(thepipe, "BROWLOG %s\n", nextarg);
  666.       nextarg = strtok((char *)NULL, " ,");
  667.     }
  668.  
  669.     nextarg = strtok(errlog, " ,");
  670.     while (nextarg != NULL) {
  671.       fprintf(thepipe, "ERRLOG %s\n", nextarg);
  672.       nextarg = strtok((char *)NULL, " ,");
  673.     }
  674.  
  675.     nextarg = strtok(reflog, " ,");
  676.     while (nextarg != NULL) {
  677.       fprintf(thepipe, "REFLOG %s\n", nextarg);
  678.       nextarg = strtok((char *)NULL, " ,");
  679.     }
  680.  
  681.     nextarg = strtok(logfile, " ,");
  682.     while (nextarg != NULL) {
  683.       fprintf(thepipe, "LOGFILE %s\n", nextarg);
  684.       nextarg = strtok((char *)NULL, " ,");
  685.     }
  686.  
  687.     nextarg = strtok(cachefile, " ,");
  688.     while (nextarg != NULL) {
  689.       fprintf(thepipe, "CACHEFILE %s\n", nextarg);
  690.       nextarg = strtok((char *)NULL, " ,");
  691.     }
  692.  
  693.     if (cm != NULL)
  694.       fprintf(thepipe, "CONFIGFILE %s\n", cm);
  695.  
  696.   }
  697.  
  698.   if (Vq)
  699.     ret = 0;
  700.   else {
  701.     fflush(thepipe);
  702.     ret = pclose(thepipe);
  703.     if (ret != 0) {
  704.       printf("Analog failed to run or returned an error code.\n");
  705.       printf("Maybe your server's error log will give a clue why.\n");
  706.     }
  707.   }
  708.   fflush(stdout);
  709.   return(ret);
  710.  
  711. }
  712.